Skip to content

fix(notifications): exclude the comment actor so they never self-notify#87

Merged
yumike merged 1 commit into
mainfrom
fix/comment-self-notify-group-owner
Jun 27, 2026
Merged

fix(notifications): exclude the comment actor so they never self-notify#87
yumike merged 1 commit into
mainfrom
fix/comment-self-notify-group-owner

Conversation

@yumike

@yumike yumike commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

Problem

When a user commented on a page inside an entity they owned, they received a notification for their own comment whenever the owner was a group they belong to. The owner-side rw.comments event addressed the owning entity (the group), and Backstage's recipient resolver expanded that group back to its members — including the actor.

Root cause: the publisher excluded the actor only by literal ref (recipients.filter(ref => ref !== actorRef)), which a group owner ref can never match.

Fix

Forward the actor as excludeEntityRef on the notification recipients. Backstage's resolver drops the actor from the resolved set after expanding groups, covering group, nested-group, and direct-user owners alike — the field's documented purpose ("the currently logged-in user, for preventing sending notification of user action to him/herself").

With exclusion correct at delivery, the publisher's literal-ref pre-filter was redundant (excludeEntityRef is a strict superset), so it's removed: actor exclusion now has a single home. The publisher emits the raw section owner / thread participants (which may include the actor) and the resolver drops the actor.

Trade-off: self-comments and sole-participant threads now publish an event that resolves to zero recipients instead of being skipped locally — one publish + one notification POST of wasted work (no catalog expansion for the direct-user case).

Tests

  • actorRef is now validated in the subscriber's shape guard (the sole basis for exclusion).
  • Added regression coverage, including an owner==actor publisher test that fails if the literal filter is reintroduced.

Verification (e2e, dev app)

  • Group member commenting on their own entity → no notification.
  • Non-member commenting → member owners still notified.
  • Owner commenting on a directly-owned entity → no notification.

🤖 Generated with Claude Code

When a user commented on a page inside an entity they owned, they received a
notification for their own comment whenever the owner was a group they belong
to. The owner-side event addressed the owning entity (a group), and Backstage's
recipient resolver expanded that group back to its members — including the
actor.

The publisher had only ever excluded the actor by literal ref
(`recipients.filter(ref => ref \!== actorRef)`), which a group owner ref can
never match. Forward the actor as `excludeEntityRef` on the notification
recipients instead: Backstage's resolver drops the actor from the resolved set
after expanding groups, covering group, nested-group, and direct-user owners
alike. This is the field's documented purpose ("the currently logged-in user,
for preventing sending notification of user action to him/herself").

With exclusion now correct at delivery, the publisher's literal-ref pre-filter
(and its empty-recipients early-exit) was redundant — `excludeEntityRef` is a
strict superset. Remove it so actor exclusion has a single home: the publisher
emits the raw section owner / thread participants (which may include the actor)
and the resolver drops the actor. Trade-off: self-comments and sole-participant
threads now publish an event that resolves to zero recipients instead of being
skipped locally; the wasted work is one publish + one notification POST (no
catalog expansion for the direct-user case).

Validates `actorRef` in the subscriber's shape guard (the sole basis for
exclusion now) and adds regression coverage, including an owner==actor publisher
test that fails if the literal filter is reintroduced.

Verified e2e: a group member commenting on their own entity gets nothing; a
non-member still notifies the member owners; an owner commenting on a directly
owned entity gets nothing.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@yumike yumike merged commit 8f4e86b into main Jun 27, 2026
1 check passed
@yumike yumike deleted the fix/comment-self-notify-group-owner branch June 27, 2026 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant